home *** CD-ROM | disk | FTP | other *** search
- #include<exec/libraries.h>
-
- #include<stdio.h>
-
- #include<clib/exec_protos.h>
-
- #include "gui.h"
- #include "idcmp.h"
- #include "loadsave.h"
-
- /* The library base global variables */
- /* (The different style of opening libraries requires these to be initialised to NULL) */
- struct Library* GfxBase = NULL;
- struct Library* IntuitionBase = NULL;
- struct Library* GadToolsBase = NULL;
- struct Library* AslBase = NULL;
- struct Library* DosBase = NULL;
- struct Library* IFFBase = NULL;
-
- /* Need to give prototypes for our functions */
- int createAll(void);
- void freeAll(void);
- int openLibs(void);
- void closeLibs(void);
-
- /* The initial screen depth */
- #define SCR_DEPTH (4)
-
- /* The start of the program */
- void main()
- {
- if(createAll())
- handleIDCMP();
- freeAll();
- }
-
- int createAll()
- {
- return openLibs() && openGUI(SCR_DEPTH,0,0,0);
- }
-
- void freeAll()
- {
- freeReqs();
- closeGUI();
- closeLibs();
- }
-
- /* Try to open all the libraries -- return TRUE on success */
- int openLibs()
- {
- if((GfxBase = OpenLibrary("graphics.library",37)) == NULL)
- {
- printf("Error: could not open graphics.library\n");
- return FALSE;
- }
- if((IntuitionBase = OpenLibrary("intuition.library",37)) == NULL)
- {
- printf("Error: could not open intuition.library\n");
- return FALSE;
- }
- if((GadToolsBase = OpenLibrary("gadtools.library",37)) == NULL)
- {
- printf("Error: could not open gadtools.library\n");
- return FALSE;
- }
- if((AslBase = OpenLibrary("asl.library",37)) == NULL)
- {
- printf("Error: could not open asl.library\n");
- return FALSE;
- }
- if((DosBase = OpenLibrary("dos.library",37)) == NULL)
- {
- printf("Error: could not open dos.library\n");
- return FALSE;
- }
- if((IFFBase = OpenLibrary("iff.library",23)) == NULL)
- {
- printf("Error: could not open iff.library\n");
- return FALSE;
- }
- return TRUE;
- }
-
- /* Close any open library */
- void closeLibs()
- {
- if(IFFBase)
- CloseLibrary(IFFBase);
- if(DosBase)
- CloseLibrary(DosBase);
- if(AslBase)
- CloseLibrary(AslBase);
- if(GadToolsBase)
- CloseLibrary(GadToolsBase);
- if(IntuitionBase)
- CloseLibrary(IntuitionBase);
- if(GfxBase)
- CloseLibrary(GfxBase);
- }
-